4. processing and sorting machine modular approach 1

在过去的几节课中,我们成功地为我们的机器创建了程序的初稿,并且,呃,我们成功地一次处理一个产品,因为我们已经讨论过这一点,但这种实现并不是最佳的,我们可以做很多事情如果我们以模块化的方式解决开发该软件的问题,效果会更好。
In the last few lessons, we managed to create the first draft of a program for our machine and, uh, we managed to process one product at a time, as we have already discussed this with this implementation is not optimal and we can do much better if we approach the problem of developing this software in a modular way.

所以现在,我们将首先尝试开发所有我们设法以模块化方式编写女教师文本的软件。
So right now, we will start by trying to develop this all the software that we manage to write instructress text in the modular way.

首先,我们先把我们在这里编写的程序放在一边。
So let's first let's put aside the program that we wrote over here.

我们将保留它作为参考,但现在我们将继续前进,我们不会使用它。
We will keep this as a reference, but for now we will move on and we will not use it.

所以我们能做的就是在应用程序中创建一个新文件夹。
So what we can do is create a new folder here in application.

正确的。
Right.

单击应用程序并创建一个文件夹。
Click on application and create a folder.

我们称之为模块化程序。
And let's call this modular program.

我们还创建一个文件夹,我们称之为,嗯。
And let's also create a folder, let's call this, um.

所有旧程序,比方说,让我们把我们在 IR 中开发的主程序移过来,让我们删除这个调用,这个函数调用到这里。
All the old program, let's say, let's move the main program that we developed in IR and let's delete this call, this function call over here.

所以现在我们不称其为任何程序。
So right now we are not calling it any program.

让我们在这里创建一个新程序,添加的实现语言应该是结构化文本,我们将这个主程序称为模块化。
And let's create here a new program that's added implementation language shall be structured text, and we will call this main program modular.

好的,那么我们将从头开始。
OK, so we will start from scratch, let's say.

这样做的目的是,首先,嗯,将机器划分为可以独立运行的不同模块,这意味着它们可以与其他任务并行管理任务。
And the purpose of this is to, first of all, um, divide the machine in different modules that can run independently, meaning that they can manage a task in parallel to the others.

所以这里我们有很多设备,我们需要真正考虑我们能做什么。
So here we have many devices and we need to actually think about what we can do.

首先,我们这里有我们的 Beston,这个人实际上可以自己移动,这意味着如果没有产品,这个人实际上可以开始自己移动并处理相同的每个产品。
So first, we have our Beston here, and this person can actually move on its own, meaning that if there is no product, either the person can actually start moving on its own and process every product that comes on the same.

肝脏也是如此。
The same goes for the liver.

肝脏可以自行工作。
The liver can work on its own.

您只需要照顾好电梯即可。
You just need to take care of the elevator.

然后我们就有了电梯,它再次可以自行移动,可以在肝脏做其他事情并且人也在做其他事情的同时处理产品。
Then we have the elevator that again can move on its own, can process products while the liver is doing other things and the person is doing the other thing as well.

然后我们有我们所说的烧烤站,我们很关心。
Then we have what we call the grilling station and we care.

这是由许多设备组成的。
This is made up of many devices.

我们的烤架和空气同时流向各处的产品。
We have the grill and the air that moves to the products over here and there in parallel.

我们有可以独立运行的表,因此我们可以将程序分为五个站。
We have the table that can run on its own so we can divide our program in five stations.

假设我将第一个称为仅由活塞组成的运行的提取站。
Let's say I will call the first one the extraction station that runs that is made up only by the piston.

所以我们在这里能做的就是创造。
So what we can do over here is create.

从中等程序文件夹中的子文件夹中取出,我们称之为该站。
And out of subfolder here in the moderate program folder, and let's call this station's.

在这里,我们可以为任何不同的站点创建不同的 polu,以便能够并行运行它们。
Over here, we can create a different polu for any different station in order to be able to run them in parallel.

如果我们有一个设备在我们的机器中多次出现,我们实际上可以为我们的其中一个站使用一个功能块。
If we had a device that appears many times in our machine, we could actually use a function block for one of our stations.

假设我们有三部电梯。
Let's say that we have three elevators.

我们可以创建一个 F 和功能块来实现电梯功能。
We could create an F and function block to implement the elevator functionality.

因此,通过这种方式,我们将能够在不同的实例上重用代码。
So in this way we were we would be able to reuse the code on different instances.

但现在我们只有任何车站的一个实例。
But right now we have just one instance of any station.

每个车站都是独一无二的。
Each station is unique.

所以对于我们关心的事情,我们实际上可以,嗯,为每个电台创建节目。
So for what concerns us, we can actually, um, create the program for each station.

我们实际上不需要创建一个像程序这样对我们有好处的函数,因为它是唯一的,并且我们没有更多同一站的实例。
We don't actually need to to create a function like a program is good for us because it is unique and we have no more instances of of the same station.

所以这里我们可以创建不同的站,不同的人使用。
So here we can create different stations, different people use.

那么让我们来创建它们。
So let's create them.

首先,我们有我所说的组成的指令站。
First of all, we have what I call the instruction station that is made up mean.

它是由活塞制成的。
It's made by the piston.

让我们创建这个。
Let's create this.

我们继续。
Let's go on.

我们有杠杆站。
We have the lever station.

所以我将其称为杠杆站。
So I will call this the lever station.

继续前行,我们看到了电梯站。
Moving on, we have the elevator station.

然后我们就有了我所说的钻井站。
Then we have what I call the drilling station.

最后我们有电缆站。
And the last we have the cable station.

车站。
The station.

好的,我们创建了五个程序。
OK, so we created five programs.

首先,我们需要做的就是将所有这些程序从我们的主程序中删除。
First, we need to do what we want to do is actually cut all these programs off from our main program.

首先,我会,嗯。
So first, I will, um.

我们要放置任务配置吗?
Are we placing the task configuration?

我害怕主程序,我只需将其拖到主任务上,然后我们就可以开始我们可以使其成为直接访问按钮和激活、传感器和激活的单站,或者将它可以通过全局变量而不是按钮来访问。
I was scared of the main program, and I will simply drag it onto the main task and then we can start by we could either make it the single station access the directly, the the buttons and the activations, the sensor and activations, or will it be access to via global variables but the buttons.

所以我们实际上可以通过两种方式获得它。
So we can actually have it in two ways.

我们可以让每个站直接访问按钮,或者我们实际上可以以不同的方式管理它们,这意味着我们可以为该站创建一些输入,以便能够真正拥有整个机器的状态流由该主程序控制。
We could have each station access directly the buttons or we could actually manage them in a different way, meaning that we could, yeah, create some inputs for the station in order to be able to actually have a flow of state for the overall machine that is controlled by this main program.

因此,我们可以做的是让我们从钻孔站开始,它是相同的,因为您将在每个站上执行此操作,然后让我们创建一组输入变量。
So what we can do is let's start by the drilling station, it is the same because you are going to do this on each on each station and let's create a set of input variables.

因此,对于我们的输入变量,我们需要实际设置为等于开始按钮的开始输入。
So for our input variables, we will need the start input that may be actually set equal to the start button.

但也可能不会,因为我们仍然必须决定如何管理车站本身。
But it also may not because we still have to decide how we will manage the station itself.

因此,让我们创建不同的输入。
So let's create different inputs.

开始输入、停止输入、保持输入和紧急情况,所以现在,这适用于我们车站的界面,而不是在我们所有的车站中复制和粘贴它。
The start input, a stop input and hold input and an emergency, so for now, this will do for the interface of our stations and less copy and paste this in all of our stations.

首先进入电梯,向下进入提取站。
First into the elevator, down into the extraction station.

桌面站的毁灭和最后。
The devastation and last of the table station.

好的,我们接下来定义来自所有发电站的所有输入。
OK, so we that then define that all the inputs from all of our power stations.

我们还需要更多的东西。
We also need something more.

我们实际上可以。
We could actually.

宣扬国家。
Propagate a state.

我的意思是,我们最好直接在我们的主模型程序“模块化”中获得一些有关该站的反馈,因此我们能做的就是实际上创建一个命令式的数据类型,这将为我们提供一些有关该站的信息。车站的当前状态。
I mean, we it would be good to have some feedback about the station directly in our main model program, Modular, so what we can do is to is actually to create and a data type in an imperative that will give us some information about the current state of the station.

所以我能做的就是在我们的模型编程文件夹中创建一个枚举,我将在站状态下调用它。
So what I can do is create an enumeration here in our model programming folder and I will call this in the station state.

我们在这里可以有不同的值,所以我们的站可以在运行状态中处于,呃,非运行状态。
And we can have different values here, so our station could be in, uh, not running state in a running state.

我被设置为等于十。
I was set equal to ten.

好吧,假设处于停止状态。
Well, let's say in a stopping state.

等于20,我会,最后,所有的状态。
Equal to 20, I will, in the end, all the states.

保持状态,让我们看看,我们还可以看到,比如说,失败状态,我们现在没有使用它,但是一旦我们处理机器上的所有诊断,它就会派上用场。
And holding state, let's see, and we can also see, let's say, a failed state, we are not using it right now, but it will come in handy once we will handle all the diagnostics on our machine.

所以我们能拥有的是每个站。
So what we can have is on each station.

关于状态的一些信息,所以让我们创建一组输出,我们称之为站状态,这可以是该触须的类型,只是一个未知的站状态。
Some information about the state, so let's create a set of outputs and that let's call this station state and this can be the type of this barbel will simply be an unknown station state.

好的。
OK.

让我们复制并粘贴这个,你知道,其他电台。
And let's copy and paste this, you know, the other stations.

好的,我们已经为我们所有的站定义了标准接口。
OK, so we have defined the standard interface for all of our station.

让我们现在开始,如果我们构建我们的程序,您实际上会发现该程序变得非常可疑,因为我们没有在代码的任何点调用它们。
Let's start let's also right now, if we build our program, you will actually see that this program becomes become great doubt because we are not calling them for any in any point of the code.

而当这些程序没有解决的时候。
And when these programs are not settled.

所以我们应该做的实际上是从我们的主程序 KARABA 中调用这个程序。
So what we should do is actually call this programs from our main program that is KARABA.

因此,在这种情况下,在这种情况下,嗯,在这种特殊情况下,我喜欢做什么,这取决于你。
So what I like to do in this this case, in this, um, in this particular case is this is up to you.

主要是我会告诉你我喜欢对你做什么。
And mainly I will show you what I like to do about you.

您只需将课程添加到您所在的课程(主课程讲师)即可。
You can simply add a course to the programs that you're in, the main program instructor.

但我喜欢做的是在联邦调查局发起一项行动。
But what I like to do is to create an action in the FBI.

我可以打电话的语言,比如我说车站呼叫和只是行动。
The language that I can call, for instance, I say station call and just action.

在这一行动中,我想调用每一个程序。
And here in this action, I would like to call each and every one of those programs.

那么让我暂时结束吧。
So let me close for now.

可视化。
The visualization.

我能做的就是拖一个盒子前辈,这样我们就把这里称为指令站吧。
What I can do is drag a box senior and let's call here the struction station in this way.

我正在调用程序。
I'm calling the program.

让我们删除问号,然后将同一行复制并粘贴五次。
Let's remove the question marks and then I copy and paste the same line five times.

第二是破坏。
The second is the devastation.

第三个是电梯。
The third one is the elevator.

站,钻井站,最后就是人民站。
Station, the drilling station, and the last is the people station.

现在,我能做的就是直接在这里添加巴顿,它们将管理我的意思,程序将如何处理,以便我们可以直接在这里传播。
And for now, what I can do is add over here directly the Bartons that will manage how the I mean, how the program will be handled so we can directly propagate here.

让我们在这里启动按钮,将所有按钮传播到我们站的输入。
Let's please start button over here, propagator all the buttons to the input of our stations.

我们现在这样做只是为了掌握它。
We will do this for now just to get a handle of it.

但我会在程序的最终版本中为您剧透。
But I will spoil it for you in the in the final version of the program.

我们实际上会改变这一点,以便呃,让我们看看,更好地控制所有电台。
We will actually change this in order to have, uh, let's see, a better control of all the stations.

因此,我们将在这里设置所有内容和停止按钮,即我们按住按钮的位置。
So here we will based everything and the stop button here, our place to hold button.

对不起,贝斯特。
Sorry, Baystate.

在这里,最后的紧急情况是紧急按钮。
Over here and then last emergencies are the emergency button.

好吧,现在假设我们正在建造的建筑没有发生任何地震,那么时间可能会在 11 点过后一点。
OK, let's say right now, if we are building without any earthquake, can be a little after 11.

好的,没有错误,但我们实际上正在运行五个错误。
OK, there are no errors, but we are actually running five.

哦,好吧,我首先需要在主程序一周后从主状态调用该操作。
Oh, well, I need first to call the action from the main state a week from the main program.

您可以按F进入文本搜索站、呼叫中心和SEMICON。
You can press F to go into text search station, call center and at SEMICON.

这样我们就可以开始了。
And this way we are you are good to go.

我们成功覆盖了五个空程序,所以这是一个起点,接下来的两个视频将开始编写该站的代码。
And we are successfully covering five empty programs, so this is a start point and the next two videos will start writing the code of the station's.